from utilities import *

from toee import *

def san_dialog( attachee, triggerer ):
	attachee.turn_towards(triggerer)
	if (attachee.leader_get() != OBJ_HANDLE_NULL):
		triggerer.begin_dialog( attachee, 250 )
	elif (game.party[0].reputation_has( 27 ) == 1): 
		triggerer.begin_dialog( attachee, 180 )
	else:
		triggerer.begin_dialog( attachee, 1 )
	return SKIP_DEFAULT

def san_enter_combat( attachee, triggerer ):
	attachee.float_line(12057,triggerer)
	return RUN_DEFAULT

def san_dying( attachee, triggerer ):
	attachee.float_line(12014,triggerer)
	return RUN_DEFAULT

def san_new_map( attachee, triggerer ):
	randy1 = game.random_range(1,16)
	if ((attachee.map == 5012) and randy1 >= 14):
		attachee.float_line(500,triggerer)
	elif ((attachee.map == 5058) and randy1 >= 13):
		attachee.float_line(510,triggerer)
	return RUN_DEFAULT

def destroy_orb( attachee, triggerer ):
	game.global_flags[326] = 1
	# set timer for 3 days and then end game
	game.timevent_add( return_Zuggtmoy, ( attachee, triggerer ), 345600000 )
	return RUN_DEFAULT	

def play_effect( attachee, triggerer ):
	# play particle effect to destroy the orb
	game.particles( 'orb-destroy', attachee )
	game.sound(4036,1)
	return RUN_DEFAULT

def return_Zuggtmoy( attachee, triggerer ):
	# play banishment movie
	game.fade(0,0,301,0)
	# play slides and end game
	set_end_slides( attachee, triggerer )
	game.moviequeue_play_end_game()
	return SKIP_DEFAULT

def switch_to_tarah( attachee, triggerer, line):
	npc = find_npc_near(attachee,8805)
	pishella = find_npc_near(attachee,8069)
	if (npc != OBJ_HANDLE_NULL):
		triggerer.begin_dialog(npc, line)
		npc.turn_towards(pishella)
		pishella.turn_towards(npc)
	return SKIP_DEFAULT
